#!/usr/bin/env bash


# ----------------------------------------------------------------------
# Filename	:  filePower
# Version	:  1.0
# Date		:  2022/02/15
# Author	:  Lz
# Email		:  liuzuo@kylinos.com.cn 
# History	:     
#            	   Version 1.0, 2022/02/15
# Function	:  文件目录缺省权限 
# Out		:        
#              0 => TPASS
#              1 => TFAIL
#              other=> TCONF
# ----------------------------------------------------------------------


# 测试主题
Title_Env_LTFLIB="安全加固(配置类) - 文件目录缺省权限"


## TODO : 个性化,初始化
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
TestInit_LTFLIB(){
	# 判断是否存在变量
	if [ "Z${FilePower_Config_SSRFlag}" == "Z" ];then
		OutputRet_LTFLIB "${ERROR}"	
		TestRetParse_LTFLIB "未定义变量 FilePower_Config_SSRFlag"
	fi

	echo ${FilePower_Config_SSRFlag} | grep -q "^[0-7][0-7][0-7]$"
	if [ $? -ne 0 ];then
		OutputRet_LTFLIB "${ERROR}"	
		TestRetParse_LTFLIB "无效值 FilePower_Config_SSRFlag = ${FilePower_Config_SSRFlag}"
	fi

        return $TPASS
}


## TODO : 清理函数
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
TestClean_LTFLIB(){
        return $TPASS
}


## TODO : 测试用例集
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
Testsuite_LTFLIB(){
        testcase_1

        return $TPASS
}


## TODO : 缺省权限，命令测试
#
testcase_1(){
	local power_num="${FilePower_Config_SSRFlag}"

	local cmd="umask"
	eval ${cmd}
	eval ${cmd} | grep -q "0${power_num}"
	CommRetParse_LTFLIB "${cmd}查询,要求权限为${power_num}"
}

## TODO : 缺省权限，文件内容(profile，bashrc)测试
#
testcase_2(){
	# 待讨论:当前仅对UID小于199用户生效
	true
}

#----------------------------------------------#

source "${LIB_LTFLIB}"
Main_LTFLIB $@
